package top.jle.wx.proxy.constant;

import com.alibaba.fastjson2.annotation.JSONType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import top.jle.wx.proxy.domain.material.Article;

import java.util.List;

public interface MaterialOption {

    int TEMPORARY_MATERIAL_EXPIRE_SECONDS = 86400*3;

    int ARTICLES_LIMIT = 8;

    @JSONType(writeEnumAsJavaBean = true)
    @Schema(title="素材类型")
    @Getter
    enum MaterialType{
        image("图片"),
        voice("语音"),
        video("视频"),
        thumb("缩略图");


        @Schema(title="类型码")
        private final String code;
        @Schema(title="类型名称")
        private final String name;

        MaterialType(String name) {
            this.code = this.name();
            this.name = name;
        }

    }

    @Schema(title="视频素材的补充信息")
    @Getter
    @Setter
    class VideoDescription{

        @Schema(title="视频素材标题")
        private String title;
        @Schema(title="视频素材介绍")
        private String introduction;
        public boolean valid(){
            return StringUtils.isNotBlank(title) && StringUtils.isNotBlank(introduction);
        }
    }
    @Schema(title="永久素材返回结果")
    @Getter
    @Setter
    class MaterialResponse{
        @Schema(title="素材ID")
        private String media_id;
        @Schema(title="图片URL",description = "新增图片素材才会有")
        private String url;
    }

    @Schema(title="临时素材返回结果")
    @Getter
    @Setter
    class TemporaryMaterialResponse{

        @Schema(title="素材类型")
        private String type;
        @Schema(title="素材ID")
        private String media_id;
        @Schema(title="缩略图素材ID")
        private String thumb_media_id;
        @Schema(title="创建时间 单位：秒")
        private Long created_at;
        @Schema(title="过期时间 单位：秒")
        private Long expire_at;
    }

    @Schema(title="素材总数结果")
    @Getter
    @Setter
    class MaterialCountResponse{
        @Schema(title="语音素材总数")
        private Integer voice_count;
        @Schema(title="视频素材总数")
        private Integer video_count;
        @Schema(title="图片素材总数")
        private Integer image_count;
        @Schema(title="图文素材总数")
        private Integer news_count;

    }
    @Schema(title="图文素材批量返回结果")
    @Getter
    @Setter
    class MaterialArticleItemResponse{
        @Schema(title="素材ID")
        private String media_id;
        @Schema(title="更新时间")
        private Long update_time;
        @Schema(title="图文列表")
        private List<Article> articles;
    }
    @Schema(title="素材批量返回结果")
    @Getter
    @Setter
    class MaterialItemResponse{
        @Schema(title="素材ID")
        private String media_id;
        @Schema(title="素材名称")
        private String name;
        @Schema(title="更新时间")
        private Long update_time;
        @Schema(title="URL")
        private String url;
    }

}
